package com.sl.au.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.sl.au.entity.AgingLedgerForFinance;

/**
 * 财务帐台台账
 * yry
 * 2018-04-06
 */
@Transactional(readOnly = true)
public interface AgingLedgerForFinanceRepository extends JpaRepository<AgingLedgerForFinance, String>{
	@Query("select i from AgingLedgerForFinance i where i.csuperior = ?1 and (i.cdemanderCode like '%'+?2+'%'"
	          +"or i.corderUnit like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
        +"or i.cdutyOfficer like '%'+?2+'%')")
	Page<AgingLedgerForFinance> getexdePayAgingAccountInfo(String superior, String key, Pageable pageable);

	@Query("select count(i) from AgingLedgerForFinance i where i.csuperior = ?1 and (i.cdemanderCode like '%'+?2+'%'"
	          +"or i.corderUnit like '%'+?2+'%' or i.careaName like '%'+?2+'%'" 
	          +"or i.cdutyOfficer like '%'+?2+'%')")
	long getCount(String superior, String key);

	@Query("select n from AgingLedgerForFinance n  where n.csuperior = ?1")
	Page<AgingLedgerForFinance> getexdePayAgingAccountInfo(String superior, Pageable pageable);

	@Query("select count(k) from AgingLedgerForFinance k where k.csuperior = ?1")
	long getCount(String superior);
	
}
